package cn.fuck;

import java.math.BigInteger;
import java.util.stream.Stream;

public class Section1_5 {
    public static void main(String[] args) {
        // peek一种用法
        Stream.iterate(BigInteger.ONE, x -> x.multiply(BigInteger.valueOf(2)))
                .peek(System.out::println)
                .limit(200).count();  // 不要忘记terminal操作, 不然就被惰性吞噬了

        Stream.of('a','z', 'a', 'h', 'c', 'i', 'm')
                .sorted()
                .peek(System.out::println)
                .count();

        System.out.println("----------------");
        Stream.of('a','z', 'a', 'h', 'c', 'i', 'm')
                .distinct()
                .sorted()
                .peek(System.out::println)
                .count();
    }
}
